package com.beyond.trace.controller.warn;

import com.beyond.trace.domain.pojo.warn.WarnRecordPageQuery;
import com.beyond.trace.service.warn.WarnRecordService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: WarnRecordController
 * @author: z越
 * @date: 2023/2/24  15:34
 * @description
 */
@RequestMapping("/warn/record")
@RestController
@Api(tags = "预警记录管理")
public class WarnRecordController {
    private final WarnRecordService warnRecordService;

    public WarnRecordController(WarnRecordService warnRecordService) {
        this.warnRecordService = warnRecordService;
    }

    @PostMapping("/page")
    @ApiOperation("分页查询预警记录")
    public AjaxResult page(@RequestBody WarnRecordPageQuery query){
        return AjaxResult.success(this.warnRecordService.findAllPages(query,true));
    }

    @GetMapping
    @ApiOperation("查询预警记录详情")
    public AjaxResult findEntity(Long id){
        return AjaxResult.success(this.warnRecordService.findById(id));
    }

    @PostMapping("/screen")
    @ApiOperation("查询预警(大屏)")
    public AjaxResult findEntity(@RequestBody WarnRecordPageQuery query){
        return AjaxResult.success(this.warnRecordService.findAllPages(query,false));
    }

    @GetMapping("/task")
    @ApiOperation("手动添加预警记录")
    public AjaxResult task(){
        this.warnRecordService.insertWarnRecord();
        return  AjaxResult.success();
    }
}
